package com.gxuwz.stats.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxuwz.stats.entity.DecisionConsulting;
import com.gxuwz.stats.entity.ScientificActivity;
import com.gxuwz.stats.entity.User;
import com.gxuwz.stats.mapper.ScientificActivityMapper;
import com.gxuwz.stats.service.ScientificActivityService;
import com.gxuwz.stats.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ScientificActivityServiceImpl extends ServiceImpl<ScientificActivityMapper, ScientificActivity> implements ScientificActivityService {
    @Autowired
    private UserService userService;
    @Override
    public IPage<ScientificActivity> getScientificActivityList(IPage<ScientificActivity>  page, QueryWrapper<ScientificActivity> queryWrapper){
        IPage<ScientificActivity> resultPage = this.page(page,queryWrapper);
        for(ScientificActivity scientificActivity : resultPage.getRecords()){
            Integer userId = scientificActivity.getUserId();
            if(userId != null){
                User user = userService.getById(userId);
                if(user != null){
                    scientificActivity.setUsername(user.getUsername());
                }
            }
        }
        return  resultPage;
    }
}
